package com.jaymin.flink.datastream.partitioner;

import org.apache.flink.api.common.functions.Partitioner;
import org.apache.kafka.common.Cluster;

import java.util.Map;

/**
 * @author jaymin
 * @since 2024/4/5 20:39
 */
public class PKPartitioner implements Partitioner<String> {

    @Override
    public int partition(String key, int numPartitions) {
        System.out.println("numPartitions:" + numPartitions);
        if ("com.imooc".equals(key)) {
            return 0;
        } else if ("com.a".equals(key)) {
            return 1;
        }
        return 2;
    }
}
